<style type="text/css">
    .libtn{margin-right: 48%; padding: 5px 0; cursor: pointer; list-style: none;float: right;}
    .disleft{float: left}
</style>
<div id="tabs" class="tabs">
    <ul>
        <li><a href="#tabs-1">Encuesta</a></li>
        <?php
        if (is_numeric($model->ENCID)) {
            echo '<li><a href="#tabs-2">Agrupar Alias en forma de Tabla</a></li>';
        }
        ?>
    </ul>
    <div id="tabs-1" class="form">   
        <div class="form">
            <?php
            $form = $this->beginWidget('GxActiveForm', array(
                'id' => 'encuestas-form',
                'enableAjaxValidation' => true,
                    ));
            ?>

            <p class="note">
<?php echo Yii::t('app', 'Campos con '); ?> <span class="required">*</span> <?php echo Yii::t('app', ' son requeridos'); ?>.
            </p>

<?php echo $form->errorSummary($model); ?>

            <div class="row">
                <?php echo $form->labelEx($model, 'ENCNOMBRE', array('class' => 'label_info')); ?>
                <?php echo $form->textArea($model, 'ENCNOMBRE', array('maxlength' => 255, 'class' => 'Ctextarea')); ?>
<?php echo $form->error($model, 'ENCNOMBRE'); ?>
            </div><!-- row -->
            <div class="row">
                <?php echo $form->labelEx($model, 'ENCVERSION', array('class' => 'label_info')); ?>
                <?php echo $form->textField($model, 'ENCVERSION', array('maxlength' => 10, 'class' => 'Cnumero')); ?>
<?php echo $form->error($model, 'ENCVERSION'); ?>
            </div><!-- row -->
            <div class="row">
<!--                <div style="float: left">-->
                    <?php echo $form->labelEx($model, 'NCLB_ID', array('class' => 'label_info')); ?>
                    <?php
                    if (is_numeric($model->ENCID)) {
                        if (Encuestasrespuestas::model()->count('ENC_ID=' . $model->ENCID) > 0)                                
                            echo $form->dropDownList($model, 'NCLB_ID', GxHtml::listDataEx(Nucleosbasicos::model()->findAll(array("order"=>"NCLBNOMBRE"), true)), array('class' => 'Ccombo', 'disabled' => 'disabled'));
                        else
                            echo $form->dropDownList($model, 'NCLB_ID', GxHtml::listDataEx(Nucleosbasicos::model()->findAll(array("order"=>"NCLBNOMBRE"), true)), array('class' => 'Ccombo'));
                    }else
                        echo $form->dropDownList($model, 'NCLB_ID', GxHtml::listDataEx(Nucleosbasicos::model()->findAll(array("order"=>"NCLBNOMBRE"), true)), array('class' => 'Ccombo'));
                    ?>
                <?php echo $form->error($model, 'NCLB_ID'); ?>
<!--                </div>-->
                <?php
                echo CHtml::link('<li class="ui-state-default ui-corner-all libtn"  title="Crear núcleo básico" ><span class="ui-icon ui-icon-plusthick" ></span></li>', array('nucleosbasicos/create&para=1', 'campo' => $model->ENCID, 'iframe' => 'true', 'width' => '100%', 'height' => '100%'), array('title' => GxHtml::encode(GxHtml::valueEx($model)), 'class' => 'pretty_nucleos'));
                ?>
            </div><!-- row -->
            <div style="clear: both"></div>
            <div style=" display: inline;" >
                <div class="row" style=" width: 49%; float:left;">
                    <?php echo $form->labelEx($model, 'ENCFECHAINICIAL', array('class' => 'label_info')); ?>
                    <?php
                    $form->widget('zii.widgets.jui.CJuiDatePicker', array(
                        'model' => $model,
                        'attribute' => 'ENCFECHAINICIAL',
                        'value' => $model->ENCFECHAINICIAL,
                        'options' => array(
                            'showButtonPanel' => true,
                            'changeYear' => true,
                            'dateFormat' => 'dd-mm-y',
                        ),
                        'htmlOptions' => array('class' => 'CfechaT', 'style' => 'cursor:pointer'),
                    ));
                    ;
                    ?>
                    <?php echo $form->error($model, 'ENCFECHAINICIAL'); ?>
                </div><!-- row -->
                <div class="row" style=" width: 49%; float:right;">
                    <?php echo $form->labelEx($model, 'ENCFECHAFINAL', array('class' => 'label_info')); ?>
                    <?php
                    $form->widget('zii.widgets.jui.CJuiDatePicker', array(
                        'model' => $model,
                        'attribute' => 'ENCFECHAFINAL',
                        'value' => $model->ENCFECHAFINAL,
                        'options' => array(
                            'showButtonPanel' => true,
                            'changeYear' => true,
                            'dateFormat' => 'dd-mm-y',
                            'constrainInput' => true
                        ),
                        'htmlOptions' => array('class' => 'CfechaT', 'style' => 'cursor:pointer'),
                            )
                    );
                    ;
                    ?>
<?php echo $form->error($model, 'ENCFECHAFINAL'); ?>
                </div><!-- row -->
                <div style="clear:both;"></div>
            </div>

            <div class="fechaaud" >
                <div  style="display: inline;" >
                    <div class="row" style=" width: 49%; float:left; text-align: center;">
                        <?php echo $form->labelEx($model, 'ENCFECHACREACION', array('class' => 'label_info')); ?>
                        <?php echo $form->textField($model, 'ENCFECHACREACION', array('disabled' => true, 'class' => 'CfechaT')); ?>
                        <?php echo $form->error($model, 'ENCFECHACREACION'); ?>
                    </div><!-- row -->
                    <div class="row" style=" width: 49%; float: right; text-align: center;">
<?php echo $form->labelEx($model, 'ENCFECHAACTUALIZACION', array('class' => 'label_info')); ?>
<?php echo $form->textField($model, 'ENCFECHAACTUALIZACION', array('disabled' => true, 'class' => 'CfechaT')); ?>
                <?php echo $form->error($model, 'ENCFECHAACTUALIZACION'); ?>
                    </div><!-- row -->
                    <div style="clear:both;"></div>
                </div>
            </div>
            <div class="center-submit">
        <?php
        echo GxHtml::submitButton(Yii::t('app', 'Guardar'), array('class' => 'add_input'));
        ?>
            </div>
        </div>
        <?php
        if (is_numeric($model->ENCID)) {
            echo '<div id="tabs-2" class="form">';
            echo '<div class="row">';
            echo '<div class="edit-pretty" >';
            echo CHtml::link('<label class="puntero">Crear Grupo de tablas</label>', array('/aliastablas/create', 'encuesta_id' => $model->ENCID, 'iframe' => 'true', 'width' => '100%', 'height' => '100%'), array('title' => GxHtml::encode(GxHtml::valueEx($model)), 'class' => 'pretty buttonA'));
            echo '</div>';


            $this->widget('zii.widgets.grid.CGridView', array(
                'id' => 'alias-tablas-grid',
                'dataProvider' => AliasTablas::search($model->ENCID),
                'columns' => array(
                    array(
                        'name' => 'INI_ALS_ID',
                        'value' => 'GxHtml::valueEx($data->iNIALS)',
                        'filter' => '',
                    ),
                    array(
                        'name' => 'FIN_ALS_ID',
                        'value' => 'GxHtml::valueEx($data->fINALS)',
                        'filter' => '',
                    ),
                    array(
                        'class' => 'CButtonColumn',
                        'template' => '{update}',
                        'updateButtonUrl' => 'Yii::app()->createUrl("/aliastablas/update", array("id" =>  $data["ALSTBLID"], "iframe"=>"True", "width"=>"100%", "height"=>"100%"))',
                        'updateButtonOptions' => array('class' => 'actualiza pretty'),
                    ),
                ),
            ));

            echo "</div>";
            echo "</div>";
            echo '<input id="encuesta_id" type="hidden" value="' . $model->ENCID . '"/>';
        }
        $this->endWidget();
        ?>
    </div><!-- form -->